<div id="viewer-container"></div>
<div class="label-info">
  <div class="btn" onclick="anima(0)">动画一</div>
  <div class="btn" onclick="anima(1)">动画二</div>
  <div class="btn" onclick="anima(2)">动画三</div>
  <div class="btn" onclick="anima(3)">动画四</div>
  <div class="btn" onclick="allIn()">一起播放</div>
</div>
<script>
  let model
  CTS.ready(() => {
    let viewer = new CTS.Viewer('viewer-container') //初始化场景
    viewer.camera.position.set(60, 40, 60) //设置相机位置
    new CTS.ModelLoder(viewer).loadModelToScene('resources/model/robot1.gltf', _model => {
      model = _model
      model.setPosition([0, -30, 0])
      let i = 0
      model.startAnima()
    })
  })

  function anima(i) {
    model.stopAnima() //开始动画之前先关闭之前播放的动画
    model.animaPlay(i)
  }

  function allIn() {
    model.animaPlay(0, b => {
      model.animaPlay(1, b => {
        model.animaPlay(2, b => {
          model.animaPlay(3, b => {
            console.log('成功---')
          })
        })
      })
    })
  }
</script>
